/**
 * 
 */
package mdb.com.vn.services;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import mdb.com.vn.model.Card;
import mdb.com.vn.model.CardSms;
import mdb.com.vn.model.Casa;
import mdb.com.vn.model.Customer;
import mdb.com.vn.model.FixedDepositCasa;
import mdb.com.vn.model.FixedDeposits;
import mdb.com.vn.model.IBanking;
import mdb.com.vn.model.IBankingSms;
import mdb.com.vn.model.Loans;
import mdb.com.vn.model.LoansSMS;
import mdb.com.vn.model.LuckyDraw;
import mdb.com.vn.model.LuckyDrawG1;
import mdb.com.vn.model.LuckyDrawG2;
import mdb.com.vn.model.Results;
import mdb.com.vn.model.SME;
import mdb.com.vn.model.ScratchCard;
import mdb.com.vn.model.SmeSms;
import mdb.com.vn.persist.CardDAO;
import mdb.com.vn.persist.CardSmsDAO;
import mdb.com.vn.persist.CasaDAO;
import mdb.com.vn.persist.CompanyDAO;
import mdb.com.vn.persist.CustomerDAO;
import mdb.com.vn.persist.FixedDepositCasaDAO;
import mdb.com.vn.persist.FixedDepositsDAO;
import mdb.com.vn.persist.IBankingDAO;
import mdb.com.vn.persist.IBankingSmsDAO;
import mdb.com.vn.persist.LoansDAO;
import mdb.com.vn.persist.LoansSmsDAO;
import mdb.com.vn.persist.LuckyDrawDAO;
import mdb.com.vn.persist.LuckyDrawG1DAO;
import mdb.com.vn.persist.LuckyDrawG2DAO;
import mdb.com.vn.persist.ResultDAO;
import mdb.com.vn.persist.ScratchCardDAO;
import mdb.com.vn.persist.SmeDAO;
import mdb.com.vn.persist.SmeSmsDAO;
import mdb.com.vn.utils.TextUtil;

/**
 * @author tu.dod
 * 
 */
@Service("mdbServices")
@Transactional
public class MDBServicesImpl implements MDBServices, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Resource(name = "fixedDepositsDAO")
	private FixedDepositsDAO fixedDepositsDAO;

	@Resource(name = "fixedDepositCasaDAO")
	private FixedDepositCasaDAO fixedDepositCasaDAO;

	@Resource(name = "casaDAO")
	private CasaDAO casaDAO;
	
	@Resource(name = "iBankingDAO")
	private IBankingDAO iBankingDAO ;
	
	@Resource(name = "cardSmsDAO")
	private CardSmsDAO cardSmsDAO ;
	
	
	@Resource(name = "iBankingSmsDAO")
	private IBankingSmsDAO iBankingSmsDAO ;
	
	@Resource(name = "loansSmsDAO")
	private LoansSmsDAO loansSmsDAO;
	
	@Resource(name = "smeSmsDAO")
	private SmeSmsDAO  smeSmsDAO;
	
	@Resource(name = "cardDAO")
	private CardDAO cardDAO;
	
	@Resource(name = "resultsDAO")
	private ResultDAO resultsDAO;
	
	@Resource(name = "luckyDrawG1DAO")
	private LuckyDrawG1DAO luckyDrawG1DAO;
	
	@Resource(name = "luckyDrawG2DAO")
	private LuckyDrawG2DAO luckyDrawG2DAO;
	
	@Resource(name = "customerDAO")
	private CustomerDAO customerDAO;

	@Resource(name = "loansDAO")
	private LoansDAO loansDAO;
	
//	@Resource(name = "loansSmsDAO")
//	private LoansSmsDAO loansSmsDAO;
	
	@Resource(name = "smeDAO")
	private SmeDAO  smeDAO;

	@Resource(name = "luckyDrawDAO")
	private LuckyDrawDAO luckyDrawDAO;

	@Resource(name = "scratchCardDAO")
	private ScratchCardDAO scratchCardDAO;

	@Resource(name = "companyDAO")
	private CompanyDAO companyDAO;

	@Override
	public List<FixedDeposits> getListOfFixedDepositsPersonal(int type) {
		// TODO Auto-generated method stub
		return fixedDepositsDAO.findByPersionalType(type);
	}

	@Override
	public List<FixedDeposits> getListOfFixedDepositsCorporate(int type) {
		// TODO Auto-generated method stub
		return fixedDepositsDAO.findByCorporateType(type);
	}

	@Override
	public List<FixedDepositCasa> getListOfFixedDepositCasaPersonal(int type) {
		// TODO Auto-generated method stub
		return fixedDepositCasaDAO.findByPersionalType(type);
	}

	@Override
	public List<FixedDepositCasa> getListOfFixedDepositCasaCorporate(int type) {
		// TODO Auto-generated method stub
		return fixedDepositCasaDAO.findByCorporateType(type);
	}

	@Override
	public List<Casa> getListOfCasaPersonal(int type) {
		// TODO Auto-generated method stub
		return casaDAO.findByPersionalType(type);
	}

	@Override
	public List<Casa> getListOfCasaCorporate(int type) {
		// TODO Auto-generated method stub
		return casaDAO.findByCorporateType(type);
	}

	@Override
	public List<Loans> getListOfLoansPersonal(int type) {
		// TODO Auto-generated method stub
		return loansDAO.findByPersionalType(type);
	}

	@Override
	public List<Loans> getListOfLoansCorporate(int type) {
		// TODO Auto-generated method stub
		return loansDAO.findByCorporateType(type);
	}

	@Override
	public void addFixedDepositCasa(FixedDepositCasa fixedDepositCasa) {
		// TODO Auto-generated method stub
		fixedDepositCasaDAO.save(fixedDepositCasa);

	}

	@Override
	public void updateFixedDepositCasa(FixedDepositCasa fixedDepositCasa) {
		// TODO Auto-generated method stub
		fixedDepositCasaDAO.update(fixedDepositCasa);

	}

	@Override
	public void deleteFixedDepositCasa(FixedDepositCasa fixedDepositCasa) {
		// TODO Auto-generated method stub
		fixedDepositCasaDAO.delete(fixedDepositCasa);

	}

	@Override
	public void addFixedDeposits(FixedDeposits fixedDeposits) {
		// TODO Auto-generated method stub
		fixedDepositsDAO.save(fixedDeposits);

	}

	@Override
	public void updateFixedDeposits(FixedDeposits fixedDeposits) {
		// TODO Auto-generated method stub
		fixedDepositsDAO.update(fixedDeposits);

	}

	@Override
	public void deleteFixedDeposits(FixedDeposits fixedDeposits) {
		// TODO Auto-generated method stub
		fixedDepositsDAO.delete(fixedDeposits);

	}

	@Override
	public void addCasa(Casa casa) {
		// TODO Auto-generated method stub
		casaDAO.save(casa);

	}

	@Override
	public void updateCasa(Casa casa) {
		// TODO Auto-generated method stub
		casaDAO.update(casa);

	}

	@Override
	public void deleteCasa(Casa casa) {
		// TODO Auto-generated method stub
		casaDAO.delete(casa);

	}

	@Override
	public void addLuckyDraw(LuckyDraw luckyDraw) {
		// TODO Auto-generated method stub
		luckyDrawDAO.save(luckyDraw);

	}

	@Override
	public void updateLuckyDraw(LuckyDraw luckyDraw) {
		// TODO Auto-generated method stub
		luckyDrawDAO.update(luckyDraw);

	}

	@Override
	public void deleteLuckyDraw(LuckyDraw luckyDraw) {
		// TODO Auto-generated method stub
		luckyDrawDAO.delete(luckyDraw);

	}

	@Override
	public void addScratchCard(ScratchCard scratchCard) {
		// TODO Auto-generated method stub
		scratchCardDAO.save(scratchCard);

	}

	@Override
	public void updateScratchCard(ScratchCard scratchCard) {
		// TODO Auto-generated method stub
		scratchCardDAO.update(scratchCard);

	}

	@Override
	public void deleteScratchCard(ScratchCard scratchCard) {
		// TODO Auto-generated method stub
		scratchCardDAO.delete(scratchCard);

	}

	@Override
	public FixedDeposits findFixedDepositsByCode(String savingBookNO) {
		// TODO Auto-generated method stub
		List<FixedDeposits> deposits = fixedDepositsDAO
				.findByCode(savingBookNO);
		for (FixedDeposits fixedDeposits : deposits) {
			return fixedDeposits;
		}
		return null;
	}

	@Override
	public String getAllLuckyDrawCodeP(String transRef, int type) {
		// TODO Auto-generated method stub
		List<LuckyDraw> LDTemps = luckyDrawDAO.findByTypeAndRef(transRef, type);
		StringBuilder stringBuilder = new StringBuilder();
		for (LuckyDraw luckyDraw : LDTemps) {
			stringBuilder.append(String.format("%05d", luckyDraw.getId()));
			stringBuilder.append("  ");

		}
		return stringBuilder.toString();
	}

	@Override
	public String getAllScratchCardCode(String transRef) {
		// TODO Auto-generated method stub
		List<ScratchCard> SCtemps = scratchCardDAO.findByRef(transRef);
		StringBuilder stringBuilder = new StringBuilder();
		for (ScratchCard scratchCard : SCtemps) {
			stringBuilder.append(scratchCard.getScDesription()).append(" ");
		}
		return stringBuilder.toString();
	}

	@Override
	public String getTotalScratchCardAmount(String transRef) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<ScratchCard> getScratchCardByRef(String transRef) {
		// TODO Auto-generated method stub
		return scratchCardDAO.findByRef(transRef);
	}

	@Override
	public String getCompanyNameByCode(String code) {
		// TODO Auto-generated method stub
		return companyDAO.findCompanyNameByCode(code);
	}

	@Override
	public Casa findCasaByCode(String accountLockedNo) {
		// TODO Auto-generated method stub
		List<Casa> casas = casaDAO.findByCode(accountLockedNo);
		for (Casa casa : casas) {
			return casa;
		}
		return null;
	}

	@Override
	public FixedDepositCasa findFixedDepositCasaByCode(String savingBookNO,
			String savingAccountNo) {
		// TODO Auto-generated method stub
		List<FixedDepositCasa> fixedDepositCasas = fixedDepositCasaDAO
				.findByCode(savingBookNO, savingAccountNo);
		for (FixedDepositCasa fixedDepositCasa : fixedDepositCasas) {
			return fixedDepositCasa;
		}
		return null;
	}

	@Override
	public int getSCardFDAvailable(String customerRef) {
		// TODO Auto-generated method stub
		return fixedDepositsDAO.getSCardFDAvailable(customerRef);
	}

	@Override
	public int getSCardCSAvailable(String customerRef) {
		// TODO Auto-generated method stub
		return casaDAO.getSCardCSAvailable(customerRef);
	}

	@Override
	public int getSCardFDCSAvailable(String customerRef) {
		// TODO Auto-generated method stub
		return fixedDepositCasaDAO.getSCardFDCSAvailable(customerRef);
	}

	@Override
	public FixedDepositCasa findFixedDepositCasaByCodeFD(String savingBookNO) {
		// TODO Auto-generated method stub
		List<FixedDepositCasa> fixedDepositCasas = fixedDepositCasaDAO
				.findByCode(savingBookNO);
		for (FixedDepositCasa fixedDepositCasa : fixedDepositCasas) {
			return fixedDepositCasa;
		}
		return null;
	}

	@Override
	public FixedDepositCasa findFixedDepositCasaByCodeCS(String savingAccountNo) {
		// TODO Auto-generated method stub
		List<FixedDepositCasa> fixedDepositCasas = fixedDepositCasaDAO
				.findByCodeCS(savingAccountNo);
		for (FixedDepositCasa fixedDepositCasa : fixedDepositCasas) {
			return fixedDepositCasa;
		}
		return null;
	}

	@Override
	public List<ScratchCard> getListOfScratchCardByTranRef(String transRef) {
		// TODO Auto-generated method stub
		return scratchCardDAO.findByRef(transRef);
	}

	@Override
	public List<ScratchCard> getListOfScratchCardByTranRef1(String transRef1) {
		// TODO Auto-generated method stub
		return scratchCardDAO.findByRef1(transRef1);
	}

	@Override
	public List<FixedDeposits> getListOfFixedDepositsByCustomerRef(
			String customerId) {
		// TODO Auto-generated method stub
		return fixedDepositsDAO.findByCustomerRef(customerId);
	}

	@Override
	public List<Casa> getListOfCasaByCustomerRef(String customerId) {
		// TODO Auto-generated method stub
		return casaDAO.findByCustomerRef(customerId);
	}

	@Override
	public List<FixedDepositCasa> getListOfFDCasaByCustomerRef(String customerId) {
		// TODO Auto-generated method stub
		return fixedDepositCasaDAO.findByCustomerRef(customerId);
	}

	@Override
	public double getAmountCorpAvailable(String customerRef) {
		// TODO Auto-generated method stub
		return fixedDepositsDAO.getAmountCorpAvailable(customerRef);
	}

	@Override
	public void deleteScratchCardByTransRef(String transRef) {
		// TODO Auto-generated method stub
		List<ScratchCard> scratchCards = scratchCardDAO.findByRef(transRef);
		for (ScratchCard scratchCard : scratchCards) {
			scratchCardDAO.delete(scratchCard);
		}
	}

	@Override
	public int getSCardFDAvailableException(String customerRef,
			String accountException) {
		return fixedDepositsDAO.getSCardFDAvailableException(customerRef, accountException);
	}

	@Override
	public int getSCardCSAvailableException(String customerRef,
			String accountException) {
		// TODO Auto-generated method stub
		return casaDAO.getSCardCSAvailableException(customerRef, accountException);
	}

	@Override
	public int getSCardFDCSAvailableException(String customerRef,
			String accountException) {
		// TODO Auto-generated method stub
		return fixedDepositCasaDAO.getSCardFDCSAvailableException(customerRef, accountException);
	}

	@Override
	public List<FixedDeposits> getAllFixedDeposits() {
		// TODO Auto-generated method stub
		return fixedDepositsDAO.getAllFixexDeposits();
	}

	@Override
	public List<Casa> getAllCasas() {
		// TODO Auto-generated method stub
		return casaDAO.getAllCasas();
	}

	@Override
	public List<FixedDepositCasa> getAllFixedDepositCasas() {
		// TODO Auto-generated method stub
		return fixedDepositCasaDAO.getAllFixedDepositCasas();
	}

	@Override
	public double getAmountCorpAvailableException(String customerRef,
			String accountException) {
		// TODO Auto-generated method stub
		return fixedDepositsDAO.getAmountCorpAvailableException(customerRef, accountException);
	}

	@Override
	public void addLoansLuckyDrawByScript(String createdBy, Date processDate) {
		// TODO Auto-generated method stub
		loansDAO.addLoansLuckyDrawByScript(createdBy, processDate);
		
	}

	@Override
	public List<Loans> getLoansByStatus(String status) {
		// TODO Auto-generated method stub
		return loansDAO.findByStatusLoans(status);
	}

	@Override
	public List<Loans> getLoansByStatusProcessDate(String status,
			Date processDate) {
		// TODO Auto-generated method stub
		return loansDAO.findByLoansProcessDateAndStaus(status, processDate);
	}

	@Override
	public Date getLastUpdatedLoans(String module) {
		// TODO Auto-generated method stub
		return loansDAO.getLastUpdated(module);
	}
	@Override
public List<SME> getSMEsByStatus(String status) {
		// TODO Auto-generated method stub
		return smeDAO.findAllSMEwithStatus(status);
	}

	@Override
	public void addSMELuckyDrawByScript(String createdBy, Date processDate) {
		smeDAO.addSMELuckyDrawByScript(createdBy, processDate);
		
	}

	@Override
	public List<SME> getSMEByStatusProcessDate(String status, Date processDate) {
		// TODO Auto-generated method stub
		return smeDAO.findBySMEProcessDateAndStatus(status, processDate);
	}

	@Override
	public List<LuckyDrawG1> getLuckyDrawG1ByRefNo(String refNo,String status) {
		// TODO Auto-generated method stub
		return luckyDrawG1DAO.findByRef(refNo, status);
	}

	@Override
	public Customer getCustomerInfos(String gcif) {
		// TODO Auto-generated method stub
		return customerDAO.getCustomerInfo(gcif);
	}

	@Override
	public int countSCByDenomination(double denomination) {
		// TODO Auto-generated method stub
		return scratchCardDAO.countByDenomination(denomination);
	}

	@Override
	public int countThanksScCard() {
		// TODO Auto-generated method stub
		return casaDAO.countThanksCard() + fixedDepositsDAO.countThanksCasrd() + fixedDepositCasaDAO.countThanksCasrd();
	}

	@Override
	public BigDecimal sumFDAmount() {
		// TODO Auto-generated method stub
		return fixedDepositsDAO.sumAmount();
	}

	@Override
	public BigDecimal sumSAAmount() {
		// TODO Auto-generated method stub
		return casaDAO.sumAmount();
	}

	@Override
	public BigDecimal sumFDCAAmount() {
		// TODO Auto-generated method stub
		return fixedDepositCasaDAO.sumAmount();
	}

	@Override
	public int countAllLuckyDraw() {
		// TODO Auto-generated method stub
		return luckyDrawDAO.countAllLuckyDraw() + luckyDrawG1DAO.countAllLuckyDraw();
	}

	@Override
	public BigDecimal sumLoansAmount() {
		// TODO Auto-generated method stub
		return loansDAO.sumAmount(TextUtil.PROCESSED);
	}

	@Override
	public String getAllLuckyDrawG1Code(String transRef, String status) {
		List<LuckyDrawG1> LDTemps = luckyDrawG1DAO.findByRef(transRef, status);
		StringBuilder stringBuilder = new StringBuilder();
		int count = 0;
		for (LuckyDrawG1 luckyDraw : LDTemps) {
			count++;
			stringBuilder.append(String.format("%05d", luckyDraw.getId()));
			if (count == LDTemps.size()){
				stringBuilder.append(" ");
			}else{
				stringBuilder.append(",");
			}
			
		}
		return stringBuilder.toString();
	}
	
	@Override
	public String getAllLuckyDrawG1Code(String transRef, String customerId,
			String status) {
		List<LuckyDrawG1> LDTemps = luckyDrawG1DAO.findByRef(transRef,customerId, status);
		StringBuilder stringBuilder = new StringBuilder();
		int count = 0;
		for (LuckyDrawG1 luckyDraw : LDTemps) {
			count++;
			stringBuilder.append(String.format("%05d", luckyDraw.getId()));
			if (count == LDTemps.size()){
				stringBuilder.append(" ");
			}else{
				stringBuilder.append(",");
			}
		}
		return stringBuilder.toString();
	}

	@Override
	public List<Date> getDatesUpdatedLoans(String module) {
		// TODO Auto-generated method stub
		return loansDAO.getDatesUpdated(module);
	}

	@Override
	public List<IBanking> getIBankingByStatus(String status) {
		// TODO Auto-generated method stub
		return iBankingDAO.findByStatus(status);
	}

	@Override
	public List<Card> getCardByStatus(String status) {
		// TODO Auto-generated method stub
		return cardDAO.findByStatus(status);
	}

	@Override
	public List<IBanking> getIBankingByStatus(String status, Date processDate) {
		// TODO Auto-generated method stub
		return iBankingDAO.findByStatus(status, processDate);
	}

	@Override
	public List<Card> getCardByStatus(String status, Date processDate) {
		// TODO Auto-generated method stub
		return cardDAO.findByStatus(status, processDate);
	}

	@Override
	public List<LuckyDrawG2> getLuckyDrawG2ByRefNo(String refNo, String status) {
		return luckyDrawG2DAO.findByRef(refNo, status);
	}

	@Override
	public String getAllLuckyDrawG2Code(String transRef,Date processDate, String type) {
		// TODO Auto-generated method stub
		List<LuckyDrawG2> LDTemps = luckyDrawG2DAO.findByRef(transRef,processDate, type);
		StringBuilder stringBuilder = new StringBuilder();
		int count = 0;
		for (LuckyDrawG2 luckyDraw : LDTemps) {
			count++;
			stringBuilder.append(String.format("%05d", luckyDraw.getId()));
			if (count == LDTemps.size()){
				stringBuilder.append(" ");
			}else{
				stringBuilder.append(",");
			}
		}
		return stringBuilder.toString();
	}

	@Override
	public void addIBLuckyDrawG2ByScript(String createdBy, Date processDate) {
		// TODO Auto-generated method stub
		iBankingDAO.addIBLuckyDrawG2ByScript(createdBy, processDate);
		
	}

	@Override
	public void addCardLuckyDrawG2ByScript(String createdBy, Date processDate) {
		// TODO Auto-generated method stub
		cardDAO.addCardLuckyDrawG2ByScript(createdBy, processDate);
		
	}

	@Override
	public void addLoanSms(LoansSMS loansSMS) {
		// TODO Auto-generated method stub
		loansSmsDAO.save(loansSMS);
	}

	@Override
	public void updateLoanSms(LoansSMS loansSMS) {
		// TODO Auto-generated method stub
		loansSmsDAO.update(loansSMS);
		
	}

	@Override
	public void deleteLoanSms(LoansSMS loansSMS) {
		// TODO Auto-generated method stub
		loansSmsDAO.delete(loansSMS);
	}

	@Override
	public List<LoansSMS> getLoansSmsByAttributes(Date processDate,
			String status) {
		// TODO Auto-generated method stub
		return loansSmsDAO.findByAttribute(processDate, status);
	}

	@Override
	public LoansSMS getLoanSmsByLD(String LD) {
		// TODO Auto-generated method stub
		return loansSmsDAO.findByLD(LD);
	}

	@Override
	public SmeSms getSmeSmsByProperties(String gcif, Date processDate) {
		// TODO Auto-generated method stub
		return smeSmsDAO.findBySmeSmsByProperties(gcif, processDate);
	}

	@Override
	public void addSmeSms(SmeSms smeSms) {
		// TODO Auto-generated method stub
		smeSmsDAO.save(smeSms);
	}

	@Override
	public void updateSmeSms(SmeSms smeSms) {
		// TODO Auto-generated method stub
		smeSmsDAO.update(smeSms);
	}

	@Override
	public void deleteSmeSms(SmeSms smeSms) {
		// TODO Auto-generated method stub
		smeSmsDAO.delete(smeSms);
	}

	@Override
	public void addIBSms(IBankingSms iBankingSms) {
		// TODO Auto-generated method stub
		iBankingSmsDAO.save(iBankingSms);
		
	}

	@Override
	public void updateIBSms(IBankingSms iBankingSms) {
		// TODO Auto-generated method stub
		iBankingSmsDAO.update(iBankingSms);
	}

	@Override
	public void deleteIBSms(IBankingSms iBankingSms) {
		// TODO Auto-generated method stub
		iBankingSmsDAO.delete(iBankingSms);
		
	}

	@Override
	public IBankingSms getIBSmsByProperties(String gcif, Date processDate) {
		// TODO Auto-generated method stub
		return iBankingSmsDAO.findByProperties(gcif, processDate);
	}

	@Override
	public List<LoansSMS> getLoansSmsByStatus(String status) {
		// TODO Auto-generated method stub
		return loansSmsDAO.findByAttribute(status);
	}

	@Override
	public List<SmeSms> findBySmeSmsByStatus(String status) {
		// TODO Auto-generated method stub
		return smeSmsDAO.findBySmeSmsByStatuss(status);
	}

	@Override
	public List<SmeSms> findBySmeSmsByStatusDate(String status, Date processDate) {
		// TODO Auto-generated method stub
		return smeSmsDAO.findByDateStatus(status, processDate);
	}

	@Override
	public List<Object> getLoansByPropertiesToExcell(String status, Date processDate) {
		// TODO Auto-generated method stub
		return loansDAO.findByPropertiesToExcell(status, processDate);
	}

	@Override
	public List<Object> getLoansByPropertiesToExcell(String status) {
		// TODO Auto-generated method stub
		return loansDAO.findByPropertiesToExcell(status);
	}

	@Override
	public List<Object> getLoansSmsByPropertiesToExcell(String status,
			Date processDate) {
		// TODO Auto-generated method stub
		return loansSmsDAO.findByPropertiesToExcell(status, processDate);
	}

	@Override
	public List<Object> getLoansSmsByPropertiesToExcell(String status) {
		// TODO Auto-generated method stub
		return loansSmsDAO.findByPropertiesToExcell(status);
	}

	@Override
	public String getAllLuckyDrawG2Code(String mudule, String transRef,
			Date processDate, String status) {
		List<LuckyDrawG2> LDTemps = luckyDrawG2DAO.findByRef(mudule, transRef,processDate, status);
		StringBuilder stringBuilder = new StringBuilder();
		int count = 0;
		for (LuckyDrawG2 luckyDraw : LDTemps) {
			count++;
			stringBuilder.append(String.format("%05d", luckyDraw.getId()));
			if (count == LDTemps.size()){
				stringBuilder.append(" ");
			}else{
				stringBuilder.append(",");
			}
		}
		return stringBuilder.toString();
	}

	@Override
	public List<IBankingSms> getIBSmsByProperties(String status) {
		// TODO Auto-generated method stub
		return iBankingSmsDAO.findByProperties(status);
	}

	@Override
	public List<IBankingSms> getIBSmsByIBSMSDateStatus(String status,
			Date processDate) {
		// TODO Auto-generated method stub
		return iBankingSmsDAO.findByDateStatus(status, processDate);
	}

	@Override
	public IBankingSms getIBSmsByID(long id) {
		// TODO Auto-generated method stub
		return iBankingSmsDAO.findIBSmsById(id);
	}

	@Override
	public CardSms getCardSmsByProperties(String gcif, String status,
			Date processDate) {
		// TODO Auto-generated method stub
		return cardSmsDAO.findByProperties(gcif, status, processDate);
	}

	@Override
	public CardSms getCardSmsByID(long id) {
		// TODO Auto-generated method stub
		return cardSmsDAO.findCardSmsById(id);
	}

	@Override
	public List<CardSms> getCardSmsByProperties(String status) {
		// TODO Auto-generated method stub
		return cardSmsDAO.findByProperties(status);
	}

	@Override
	public List<CardSms> getCardSmsByIBSMSDateStatus(String status,
			Date proccessDate) {
		// TODO Auto-generated method stub
		return cardSmsDAO.findByDateStatus(status, proccessDate);
	}

	@Override
	public void addCardSms(CardSms cardSms) {
		// TODO Auto-generated method stub
		cardSmsDAO.save(cardSms);
		
	}

	@Override
	public void updateCardSms(CardSms cardSms) {
		// TODO Auto-generated method stub
		cardSmsDAO.update(cardSms);
	}

	@Override
	public void deleteCardSms(CardSms cardSms) {
		// TODO Auto-generated method stub
		cardSmsDAO.delete(cardSms);
	}

	@Override
	public LuckyDraw getLuckyDrawById(long id) {
		// TODO Auto-generated method stub
		return luckyDrawDAO.findById(id);
	}

	@Override
	public LuckyDrawG1 getLuckyDrawG1ById(long id) {
		// TODO Auto-generated method stub
		
		return luckyDrawG1DAO.findById(id);
	}

	@Override
	public LuckyDrawG2 getLuckyDrawG2ById(long id) {
		// TODO Auto-generated method stub
		return luckyDrawG2DAO.findById(id);
	}

	@Override
	public List<Results> getListResults() {
		// TODO Auto-generated method stub
		return resultsDAO.getListResults();
	}

	@Override
	public void addResult(Results results) {
		resultsDAO.save(results);
	}

}
